﻿using Azure.QPCR;

namespace Azure2Java.QPCRAdapter.Adapter {

    /**
     * @author zy gws ssc
     * @date 18.12.21
     * @update 19.12.06
     * @decription DeviceInfo代理类
     */
    public class DeviceInfoAdapter {
        public DeviceInfo DeviceInfo;

        public DeviceInfoAdapter() {
            DeviceInfo = new DeviceInfo();
        }

        public DeviceInfoAdapter(DeviceInfo DeviceInfo) {
            this.DeviceInfo = DeviceInfo;
        }

        public void setId(string id) {
            DeviceInfo.ID = id;
        }

        public string getId() {
            return DeviceInfo.ID;
        }

        public void setConnectPort(string connectPort) {
            DeviceInfo.ConnectPort = connectPort;
        }

        public string getConnectPort() {
            return DeviceInfo.ConnectPort;
        }

        public void setName(string name) {
            DeviceInfo.Name = name;
        }

        public string getName() {
            return DeviceInfo.Name;
        }

        public void setProductName(string productName) {
            DeviceInfo.ProduceName = productName;
        }

        public string getProductName() {
            return DeviceInfo.ProduceName;
        }

        public void setSoftwareVersion(string softWareVersion) {
            DeviceInfo.SoftwareVersion = softWareVersion;
        }

        public string getSoftwareVersion() {
            return DeviceInfo.SoftwareVersion;
        }

        public void setHardwareVersion(string hardwareVersion) {
            DeviceInfo.HardwareVersion = hardwareVersion;
        }

        public string getHardwareVersion() {
            return DeviceInfo.HardwareVersion;
        }


        // public enum ConnectStatus {
        //     NONE = 0,
        //     CONNECTED = 1,
        //     DISCONNECTED = 2
        // }
        public string getConnectStatus() {
            ConnectStatus status = DeviceInfo.ConnectStatus;
            switch(status) {
                case ConnectStatus.NONE:
                    return "none";
                case ConnectStatus.CONNECTED:
                    return "connect";
                case ConnectStatus.DISCONNECTED:
                default:
                    return "disconnect";
            }
        }

        public void setConnectStatus(string status) {
            switch(status) {
                case "none":
                    DeviceInfo.ConnectStatus = ConnectStatus.NONE;
                    return;
                case "connect":
                    DeviceInfo.ConnectStatus = ConnectStatus.CONNECTED;
                    return;
                case "disconnect":
                default:
                    DeviceInfo.ConnectStatus = ConnectStatus.DISCONNECTED;
                    return;
            }
        }

        // public enum ConnectType {
        //     NONE = 0,
        //     SERIAL = 1,
        //     NETWORK = 2
        // }
        public string getConnectType() {
            ConnectType type = DeviceInfo.ConnectType;
            switch(type) {
                case ConnectType.NONE:
                default:
                    return "none";
                case ConnectType.SERIAL:
                    return "serial";
                case ConnectType.NETWORK:
                    return "network";
            }
        }

        public void setConnectType(string type) {
            switch(type) {
                case "none":
                default:
                    DeviceInfo.ConnectType = ConnectType.NONE;
                    return;
                case "serial":
                    DeviceInfo.ConnectType = ConnectType.SERIAL;
                    return;
                case "network":
                    DeviceInfo.ConnectType = ConnectType.NETWORK;
                    return;
            }
        }


        public bool equals(object other) {
            return DeviceInfo.Equals(other);
        }

        public int getHashCode() {
            return DeviceInfo.GetHashCode();
        }
    }
}
